package com.lhy.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.lhy.entity.Emp;
import com.lhy.mapper.EmpMapper;
import com.lhy.service.EmpService;
import com.lhy.vo.EchartsVo;
import com.lhy.vo.EmpVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


import java.time.LocalDateTime;
import java.util.Date;
import java.util.List;

/**
 * @Author：罗昊宇
 * @Package：com.lhy.service.impl
 * @Project：springboot03
 * @name：EmpServiceImpl
 * @Date：2024/3/11 0011  18:44
 * @Filename：EmpServiceImpl
 */
@Service
public class EmpServiceImpl implements EmpService {
    @Autowired
    private EmpMapper empMapper;
    public PageInfo<Emp> getAll(Integer current, Integer pageSize, EmpVo empVo) {
        PageHelper.startPage(current,pageSize);
        List<Emp> empList = empMapper.getAll(empVo);
        PageInfo<Emp> pageInfo =new PageInfo<Emp>(empList);


        return pageInfo;
    }

    public Integer deleteEmp(Integer id) {

        Integer deleteEmp = empMapper.deleteEmp(id);

        return deleteEmp;
    }

    public int insertEmp(Emp emp) {

        Date date = new Date();
        emp.setCreateTime(date);
        emp.setUpdateTime(date);
        int agg = empMapper.insertEmp(emp);
        return agg;
    }

    @Override
    public Integer updateEmp(Emp emp) {
        Date date =new Date();
        emp.setEntrydate(date);
        emp.setDeptId(emp.getDeptName());
        Integer updateEmp = empMapper.updateEmp(emp);
        return updateEmp;
    }

    @Override
    public List<EchartsVo> getByCount(EchartsVo echartsVo) {
        List<EchartsVo> count = empMapper.getByCount(echartsVo);

        return count;
    }

    @Override
    public List<EchartsVo> getByCount2(EchartsVo echartsVo) {

        return empMapper.getByCount2(echartsVo);
    }
}
